<template>
  <el-form :inline="false" :model="formInline" class="demo-form-inline">
    <el-form-item label="请输入案件名:">
      <el-input v-model="formInline.name" placeholder="请输入案件名"  />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">创建</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'
import { ElMessage } from 'element-plus'
import {useTaskStore,usePageShowStore} from '../stores/index'

const formInline = reactive({
  name: '',
  date: new Date().toLocaleString()
})

const taskStore = useTaskStore()
const pageShowStore = usePageShowStore()
const onSubmit = () => {
  formInline.date = new Date().toLocaleString()
  if (formInline.name == "") {
    ElMessage.error('案件名不能为空！')
    return
  }
  window.send_main.create_task({"task_name":formInline.name,"create_time":formInline.date}, (result) => {
    // 处理查询结果
    if (result == 0) {
      ElMessage.error('案件名存在！')
    } else {
      //刷新任务列表
      taskStore.loadData()
      //跳转到下一步
      taskStore.upload_task_id = result//设置任务id
      pageShowStore.active = "1-2"
    }
  });

}
</script>

<style>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}
</style>
